#pragma once
#include "vec3.h"
#include <vector>

namespace mray{

	struct Ray;
	struct Collible;
	struct AABB;

	struct Edge{
		enum TYPE : unsigned char{START, END};
		bool operator < (const Edge& e);

		float		m_t;
		TYPE		m_type;
		const AABB*	m_aabb;
	};

	struct AABB {

		AABB();
		AABB(const vec3& min, const vec3& max);

		AXIS GetMaxExtent()const;
		void GetEdge(Edge& e, AXIS axis, Edge::TYPE type)const;
		float GetSurfaceArea()const;
		float GetSurfaceArea(AXIS axis, float t, bool below)const;
		float GetLengthWidthHeight()const;
		bool Split(AXIS axis, float t, AABB& lowBox, AABB& highBox)const;
		bool Contain(const vec3& v)const;
		void Fromat();
		void Reset();

		AABB operator &(const AABB& b)const;
		AABB operator &(const vec3& v)const;
		const AABB& operator &= (const AABB& b);
		const AABB& operator &= (const vec3& v);

		bool Hit(Ray& ray)const;

		union{
			struct {vec3 m_min, m_max;};
			struct {vec3 m_data[2];};
		};
		const Collible* m_object;
	};
}